package nju.mscs.data;

import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.net.ServerSocket;
import java.net.Socket;

public class NetManager {
	public ServerSocket setServer(int port) throws IOException{
		ServerSocket ss = new ServerSocket(port);
		return ss;
	}
	public void writeToSocket(Object obj,Socket socket) throws IOException{
		ObjectOutputStream oos = new ObjectOutputStream(socket.getOutputStream());
		oos.writeObject(obj);
		//oos.close();
		//socket.close();
	}
	public Object readFromSocket(Socket socket) throws IOException, ClassNotFoundException{
		ObjectInputStream ois = new ObjectInputStream(socket.getInputStream());
		return ois.readObject();
	}
}
